﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views {
    import flash.events.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.vo.*;
    import net.wooga.pets.views.components.*;
    import net.wooga.pets.constants.*;

    public class RoofMediator extends RenderListMediator {

		[Inject]
        public var roofDisplay:RoofDisplay;

        override public function onRegister():void{
            super.onRegister();
            eventMap.mapListener(eventDispatcher, UpdateDisplayEvent.UPDATE_ROOF_DISPLAY, this.updateDisplay);
            eventMap.mapListener(eventDispatcher, CreationEvent.CREATE_INTERSOL, this.onCreateIntersol);
            eventMap.mapListener(eventDispatcher, CommandConstants.CLEAR_SCENE, this.clearScene);
            eventMap.mapListener(eventDispatcher, CustomizeEvent.ITEM_CLICKED, this.onItemClicked);
            eventMap.mapListener(eventDispatcher, EventConstants.REMOVE_SNAPAREAS, this.onRemoveSnapareas);
            eventMap.mapListener(this.roofDisplay, EventConstants.SNAP_IN, this.onSnapIn);
            eventMap.mapListener(this.roofDisplay, EventConstants.SNAP_OUT, dispatch);
        }
        private function onSnapIn(_arg1:SnapEvent):void{
            dispatch(_arg1.clone());
        }
        private function onCreateIntersol(_arg1:CreationEvent):void{
            var _local2:Number = ((_arg1.body.y - (GameConstants.ROOM_HEIGHT / 2)) - (this.roofDisplay.height / 2));
            this.roofDisplay.y = _local2;
        }
        private function updateDisplay(_arg1:UpdateDisplayEvent):void{
            if (_arg1.id == this.roofDisplay.id){
                this.roofDisplay.y = _arg1.y;
                updateRenderList();
            };
        }
        private function onItemClicked(_arg1:CustomizeEvent):void{
            switch (_arg1.destination){
                case ShopItemVO.DESTINATION_ROOF:
                    this.roofDisplay.initSnaparea();
                    break;
            };
        }
        private function onRemoveSnapareas(_arg1:Event):void{
        }
        private function clearScene(_arg1:Event):void{
            this.roofDisplay.remove();
        }

    }
}//package net.wooga.pets.views 
